﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Import Namespace="ThuatToan.Utils"%>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
    <title>ThuatToan.Org</title>
    
    <script type="text/javascript">
        function validateInput() {
            var input = document.getElementById('ctl00_ContentPlaceHolder1_txtInput');

            if (input.value.trim().length <= 2) {

                alert('Hãy nhập nhiều hơn 2 ký tự để tìm kiếm');
                return false;
            }
            else {

                return true;
            }
        }
    </script>
    
    <link href="Css/cbdb-search-form.css" type="text/css" rel="stylesheet" media="screen" />
    <style type="text/css">
        .style1
        {
            width: 100%;
        }
        
        .search
        {
        	width: 727px;
        	background: #999;
        }
        .style2
        {
            width: 393px;
            text-align: center;
        }
        .style3
        {
            width: 114px;
        }
        
        .result
        {
        	width: 727px;
        }
        .style4
        {
            width: 393px;
            text-align: center;
            font-size: medium;
            color: #FFFFFF;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

    <div class="search">
    <table class="style1" width="100%" cellpadding="3">
        <tr>
            <td class="style3">
                &nbsp;</td>
            <td class="style4">
                <strong>NHẬP TÊN THUẬT TOÁN</strong></td>
            <td>
                &nbsp;</td>
        </tr>
        <tr>
            <td class="style3" style="text-align: right">
                &nbsp;</td>
            <td class="style2">
                <asp:TextBox ID="txtInput" runat="server" Width="384px"></asp:TextBox> </td>
            <td>
                <asp:Button ID="btnSearch" runat="server" Text="Tìm kiếm" 
                    onclick="btnSearch_Click" 
                    onclientclick="javascript:return validateInput();" /></td>
            
        </tr>
    </table>

</div>

<div class="result">
    <asp:Label ID="lbl_Norecord" runat="server" 
        Text="0 kết quả, hãy nhập tiếng việt có dấu để tìm chính xác hơn!" 
        Font-Size="Medium" ForeColor="Red" Visible="False"></asp:Label>
    <asp:GridView ID="GridView1" runat="server" BackColor="White" 
        BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" CellPadding="3" 
        EnableModelValidation="True" Width="100%" AutoGenerateColumns="False">
        <Columns>
            <asp:TemplateField HeaderText="Thuật Toán">
                <ItemTemplate>
                    <img alt="star" src="Images/icon_star.gif" />
                    <asp:HyperLink ID="hpl_ItemName" runat="server"
                        Font-Underline="False" ForeColor="#AA0000"
                        Font-Size="Small" 
                        NavigateUrl='<%# "~/it_" + StringUtil.Convert_Chuoi_Khong_Dau(Eval("Name").ToString()) + "-" + Eval("ItemID").ToString() + ".aspx" %>'
                        Text='<%# Eval("Name") %>'>
                    </asp:HyperLink>
                </ItemTemplate>
                <ItemStyle BorderColor="#666699" HorizontalAlign="Left" />
            </asp:TemplateField>

            <asp:TemplateField HeaderText="Thể Loại">
                <ItemTemplate>
                    <asp:HyperLink ID="hpl_CategoryName" runat="server"
                        Font-Underline="False" ForeColor="#125D89"
                        Font-Size="Small" 
                        NavigateUrl='<%# "~/ct_" + StringUtil.Convert_Chuoi_Khong_Dau(Eval("CategoryName").ToString().Trim()) + "-" + Eval("CategoryID").ToString().Trim() + ".aspx" %>'
                        Text='<%# Eval("CategoryName") %>'>
                    </asp:HyperLink>
                </ItemTemplate>
                <HeaderStyle HorizontalAlign="Center" Width="200px"/>
                <ItemStyle BorderColor="#666699" HorizontalAlign="Center"/>
            </asp:TemplateField>
            
        </Columns>
        
        <FooterStyle BackColor="White" ForeColor="#000066" />
        <HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" />
        <PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" />
        <RowStyle ForeColor="#000066" />
        <SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
    </asp:GridView>
    <br />
    <div class="shortlink">
        <% ThuatToanDAO.ItemDAO item = new ThuatToanDAO.ItemDAO();
           System.Data.DataSet ds = item.ExecuteSelectTopView();
           foreach (System.Data.DataRow row in ds.Tables[0].Rows)
		   { %>
                <a href='<%= "it_" + StringUtil.Convert_Chuoi_Khong_Dau(row["Name"].ToString()) + "-" + row["ItemID"].ToString() + ".aspx" %>'><%= row["Name"].ToString() %></a>
                ,
        <% } %>
        
    </div>

    <%--     <div class="center">
         <% string formatstring = "Search.aspx?thuattoan=" + thuattoan + "&pageid={0}";  %>
         <%= SimplePage.SimplePager(currentPage, numberOfPage, formatstring, "pagination", "number", string.Empty, false).ToString()%>
    </div>--%>
    
</div>
</asp:Content>

